/******************************************************
Standard XOR Encryption By Axion
UIN : 35614954
EMAIL: axionis@hotmail.com
DATE : MAY 21st 2000
USAGE: xe filein fileout key
*******************************************************/
#include <stdio.h>
#define PROG_NAME "xe"
void usage()
{
printf("-------------------------------\n");
printf("Invalid command line.\n");
printf("Usage:\n\t%s infile outfile key\n", PROG_NAME);
printf("-------------------------------\n");
}
int main(int argc, char *argv[])
{
int count,bytes; /* counter when looping through file, and bytes to count filesize */
FILE *in,*out; /* In and out FILE Streams to read/write data */
if(argc < 4) { /* Error check the command line */
usage(); /* Display Usage Information on error */
return 0; /* Exit Program returning 0 - no error */
}
if (( in = fopen(argv[1], "rb")) == NULL) /* Error Check File Streams */
{
printf("Error opening %s.\n", argv[1]);
}
if (( out = fopen(argv[2], "wb")) == NULL)
{
printf("Error opening %s.\n", argv[2]);
}
while(( count = getc(in)) != EOF)
{
count = count ^ *argv[3]; /* Apply XOR ( KEY ) */
bytes++; /* Increment counter of filesize */
putc(count, out); /* Write new file */
}
fclose(in);
fclose(out);
printf("Encryption Success:\n");
printf("\tEncrypted %s and stored data in %s.\n", argv[1],argv[2]);
printf("\tWrote %d bytes to %s.\n", bytes,argv[2]);
return 0;
}
/* To compile under djgpp */
/* dgjpp xe.c -o xe */